<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>取派标准</title>
<!-- 导入jquery核心类库 -->
<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css"
	href="../../js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="../../js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="../../js/easyui/ext/portal.css">
<link rel="stylesheet" type="text/css" href="../../css/default.css">
<script type="text/javascript"
	src="../../js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="../../js/easyui/ext/jquery.portal.js"></script>
<script type="text/javascript"
	src="../../js/easyui/ext/jquery.cookie.js"></script>
<script src="../../js/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>
<script type="text/javascript">
	$.fn.serializeJson=function(){  
	    var serializeObj={};  
	    var array=this.serializeArray();
	    $(array).each(function(){  
	        if(serializeObj[this.name]){  
	            if($.isArray(serializeObj[this.name])){  
	                serializeObj[this.name].push(this.value);  
	            }else{  
	                serializeObj[this.name]=[serializeObj[this.name],this.value];  
	            }  
	        }else{  
	            serializeObj[this.name]=this.value;   
	        }  
	    });  
	    return serializeObj;  
	}; 

	$(function() {
		// 先将body隐藏，再显示，不会出现页面刷新效果
		$("body").css({
			visibility : "visible"
		});

		// 收派标准信息表格
		$('#grid').datagrid({
			iconCls : 'icon-forward',
			fit : true,
			fitColumns:true,
			border : false,
			rownumbers : true,
			striped : true,
			pageList : [ 30, 50, 100 ],
			pagination : true,
			toolbar : toolbar,
			url : "../../standardAction_page.action",
			idField : 'id',
			columns : columns
		});
	});

	//工具栏
	var toolbar = [ {
		id : 'button-add',
		text : '增加',
		iconCls : 'icon-add',
		handler : function() {
			// alert('增加');
			$("#standardWindow").window('open');
		}
	}, {
		id : 'button-edit',
		text : '修改',
		iconCls : 'icon-edit',
		handler : function() {
			// 首先判断是否只是选择的一条数据
			var arr = $("#grid").datagrid("getSelections");
			if (arr.length != 1){
				$.messager.alert("提示信息","每次只能选择一条数据进行修改!","warning");
			}else{
				// 弹出修改的窗口
				$("#updateStandardWindow").window('open');
				// 把选择行的数据，加载表单中
				var rowData = arr[0];
				$("#updateStandardForm").form("load",rowData);
			}
		}
	}, {
		id : 'button-delete',
		text : '作废',
		iconCls : 'icon-cancel',
		handler : function() {
			var arr = $("#grid").datagrid("getSelections");
			if (arr.length == 0){
				$.messager.alert("提示信息","删除操作至少要选择一行!","warning");
			}else{
				var idsArr = new Array();
				for (var i=0; i < arr.length; i++){
					idsArr.push(arr[i].id);
				}
				var ids = idsArr.join(",");
				$.messager.confirm('确认信息', '确认要删除选中的取派标准?', function(r){
					if (r){
						location.href = "../../standardAction_delete.action?ids="+ids;
					}
				});
						
			}
		}
	} ];

	// 定义列
	var columns = [ [ {
		field : 'id',
		checkbox : true
	}, {
		field : 'name',
		title : '标准名称',
		width : 120,
		align : 'center'
	}, {
		field : 'minWeight',
		title : '最小重量',
		width : 120,
		align : 'center'
	}, {
		field : 'maxWeight',
		title : '最大重量',
		width : 120,
		align : 'center'
	}, {
		field : 'minLength',
		title : '最小长度',
		width : 120,
		align : 'center'
	}, {
		field : 'maxLength',
		title : '最大长度',
		width : 120,
		align : 'center'
	}, {
		field : 'operator',
		title : '操作人',
		width : 120,
		align : 'center'
	}, {
		field : 'modifieTime',
		title : '操作时间',
		width : 120,
		align : 'center'
	}, {
		field : 'company',
		title : '操作单位',
		width : 120,
		align : 'center'
	} ] ];

	$(function() {
		// 新增标准保定事件
		$("#save").click(function() {
			// 如果表单校验通过就提交表单
			var boolRes = $("#addStandardForm").form('validate');
			if (boolRes) {
				$("#addStandardForm").submit();
			}
		});
		
		// 为修改按钮绑定shijian
		$("#update").click(function(){
			var boolRes = $("#updateStandardForm").form('validate');
			if (boolRes){
				$("#updateStandardForm").submit();
			}
		});

	});
</script>
</head>

<body class="easyui-layout" style="visibility: hidden;">
	<div region="center" border="false">
		<table id="grid"></table>
	</div>

	<div class="easyui-window" title="添加收派标准" id="standardWindow"
		collapsible="false" minimizable="false" maximizable="false"
		modal="true" closed="true"
		style="width: 600px; top: 50px; left: 200px">
		<div region="north" style="height: 31px; overflow: hidden;"
			split="false" border="false">
			<div class="datagrid-toolbar">
				<a id="save" icon="icon-save" href="javascript:void(0)"
					class="easyui-linkbutton" plain="true">保存</a>
			</div>
		</div>

		<div region="center" style="overflow: auto; padding: 5px;"
			border="false">

			<form id="addStandardForm" action="../../standardAction_add.action"
				method="post">
				<table class="table-edit" width="80%" align="center">
					<tr class="title">
						<td colspan="2">收派标准信息 <!--提供隐藏域 装载id --> <input
							type="hidden" name="id" />
						</td>
					</tr>
					<tr>
						<td>收派标准名称</td>
						<td>
						<input type="text" name="name" class="easyui-validatebox"
							validtype="remote['../../standardAction_validate.action','name']"
							required="true" missingMessage="收派标准名称不能为空"
							invalidMessage="收派标准名称已存在" />
						</td>
					</tr>
					<tr>
						<td>最小重量</td>
						<td><input type="text" name="minWeight"
							class="easyui-numberbox" required="true" /></td>
					</tr>
					<tr>
						<td>最大重量</td>
						<td><input type="text" name="maxWeight"
							class="easyui-numberbox" required="true" /></td>
					</tr>
					<tr>
						<td>最小长度</td>
						<td><input type="text" name="minLength"
							class="easyui-numberbox" required="true" /></td>
					</tr>
					<tr>
						<td>最大长度</td>
						<td><input type="text" name="maxLength"
							class="easyui-numberbox" required="true" /></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	
	<!-- 修改收派标准的window -->
	<div class="easyui-window" title="修改收派标准" id="updateStandardWindow"
		collapsible="false" minimizable="false" maximizable="false"
		modal="true" closed="true"
		style="width: 600px; top: 50px; left: 200px">
		<div region="north" style="height: 31px; overflow: hidden;"
			split="false" border="false">
			<div class="datagrid-toolbar">
				<a id="update" icon="icon-save" href="javascript:void(0)"
					class="easyui-linkbutton" plain="true">修改</a>
			</div>
		</div>

		<div region="center" style="overflow: auto; padding: 5px;"
			border="false">

			<form id="updateStandardForm" action="../../standardAction_update.action"
				method="post">
				<table class="table-edit" width="80%" align="center">
					<tr class="title">
						<td colspan="2">收派标准信息
						<!--提供隐藏域 装载id --> 
						<input
							type="hidden" name="id" />
						</td>
					</tr>
					<tr>
						<td>收派标准名称</td>
						<td>
							<!-- <input type="text" name="name" class="easyui-validatebox"
								validtype="remote['../../standardAction_validate.action','name']"
								required="true" missingMessage="收派标准名称不能为空"
								invalidMessage="收派标准名称已存在" /> -->
								<input type="text" name="name" readonly="readonly"/>
						</td>
					</tr>
					<tr>
						<td>最小重量</td>
						<td><input type="text" name="minWeight"
							class="easyui-numberbox" required="true" /></td>
					</tr>
					<tr>
						<td>最大重量</td>
						<td><input type="text" name="maxWeight"
							class="easyui-numberbox" required="true" /></td>
					</tr>
					<tr>
						<td>最小长度</td>
						<td><input type="text" name="minLength"
							class="easyui-numberbox" required="true" /></td>
					</tr>
					<tr>
						<td>最大长度</td>
						<td><input type="text" name="maxLength"
							class="easyui-numberbox" required="true" /></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>

</html>